package com.szrt.day20170427.designmodel.demo04;


import static org.junit.Assert.*;

import org.junit.Test;

public class ProxyTest {
	
	
	
	@Test
	public void add() throws Exception {
		StudentService service  = new StudentServiceImpl();
		
		DynProxy proxy  = new DynProxy(service);
		Object obj = proxy.getaab();
		
		
		//强制转化
		StudentService proxyObj = (StudentService) obj;
		
		proxyObj.add("zxx", "123");
		//System.err.println(obj);
	}
	
	@Test
	public void studentFTest() throws Exception {
		
		StudentService service  = new StudentServiceImpl();
		
		DynProxy proxy  = new DynProxy(service);
		Object obj = proxy.getaab();
		
		
		//强制转化
		StudentService proxyObj = (StudentService) obj;
		
		proxyObj.findByPhone("123");
		
		
	}
	
	@Test
	public void teacherTest() throws Exception {
		
		TeacherService service  = new TeacherServiceImpl();
		
		
		DynProxy proxy  = new DynProxy(service);
		Object obj = proxy.getaab();
		
		
		//强制转化
		TeacherService proxyObj = (TeacherService) obj;
		proxyObj.addTeacher("lxx");
		
	}

}
